home *** CD-ROM | disk | FTP | other *** search
/ Stolen Data 3 / Stolen Data 3.adf / SOURCE / Scroller2.bak < prev    next >
Text File  |  1988-12-31  |  8KB  |  326 lines

  1. *****************************************************************************
  2. ;                         STOLEN DATA Issue #3
  3. ;                         ~~~~~~~~~~~~~~~~~~~~
  4. ;   Double buffered base relief scroller
  5. ;
  6. ;   Copyright ANARCHY 1990
  7. ;
  8. ;   Written on 3.6.90 by Kreator of ANARCHY
  9. ;
  10. ;  General notes - At all times (unless specified) a6 points to the custom
  11. ; chip registers ($dff000) and a5 points to the list of variables.This allows
  12. ; indirect addressing modes to be used, which are much faster than absolute
  13. ; addressing and consume less memory. If these registers are needed in the
  14. ; course of a routine simply stick them on the stack, and pop them back off
  15. ; later.
  16. *****************************************************************************
  17.  
  18.     Incdir    DF1:
  19.     Include    Source/NewCustomReg    ; Custom register label equates
  20.     Section    Scroller,Code_c        ; Assemble into chip mem if > ½ meg
  21.  
  22. Trap_vec0    = $80
  23. Execbase    = $4
  24. Oldopen        = -$198
  25.  
  26.     Move.l    #Start,$80.w    ; Trap vector 0
  27.     Trap    #0        ; Execute trap 0 to give full control of the
  28.     Rts            ; 68000, needs an RTE to return.
  29.  
  30. Start
  31.     Bsr    Killsys        ; Disable the operating system
  32.     Bsr    Setup        ; Setup the demo
  33.     Bsr    Main        ; Now run the main demo routines
  34.     Bsr    Sysreturn    ; Return the system to its original state
  35.     Moveq.l    #0,d0        ; No errors !! A number of people neglect to
  36.                 ; do this, and that causes batch files (such
  37.                 ; as the startup sequence) to bomb out.
  38.     Rte        ; Return from exception ie. to the instruction after
  39.             ; the TRAP #0 call.
  40.  
  41. *****************************************************************************
  42. ;Killsys - Disable operating system and interrupts
  43. *****************************************************************************
  44. Killsys
  45.     Move.l    $4.w,a6        ; Execbase vector
  46.     Lea    Gfxname(pc),a1    ; Pointer to "graphics.library" into a1
  47.     Jsr    Oldopen(a6)    ; Open this library
  48.     Lea    Variables,a5    ; Get a pointer to the variable space
  49.     Lea    $dff000,a6    ; Pointer to custom chips
  50.     Move.l    d0,a0        ; Address of the graphics library
  51.     Move.l    38(a0),Sys_copl(a5)    ; Remember the System copperlist
  52.     Move    Intenar(a6),Int_set(a5)    ; System interrupts
  53.     Move    #$7fff,Intena(a6)    ; Now switch off all interrupts
  54.     Move.l    $6c.w,Vbl_vec(a5)    ; System vertical blanking int.
  55.     Move    Dmaconr(a6),Dma_set(a5)    ; System DMA
  56.     Move    #$7fff,Dmacon(a6)    ; Clear all DMA
  57.     Move    #$87c0,Dmacon(a6)    ; Now set the required DMA channels
  58.     Rts
  59.  
  60. Gfxname        Dc.b "graphics.library",0
  61.     Even
  62. *****************************************************************************
  63. ;Sysreturn - Re-enable operating system and interrupts
  64. *****************************************************************************
  65. Sysreturn
  66.     Move    #$7fff,Intena(a6)    ; Clear all interrupts
  67.     Move.l    Vbl_vec(a5),$6c.w    ; Restore VBL interrupt
  68.     Move    Int_set(a5),d0
  69.     Or    #$c000,d0
  70.     Move    d0,Intena(a6)        ; Restore system interrupts
  71.     Move    #$7fff,Dmacon(a6)
  72.     Move    Dma_set(a5),d0
  73.     Or    #$8200,d0
  74.     Move    d0,Dmacon(a6)        ; Restore system DMA
  75.     Move.l    Sys_copl(a5),Cop1lch(a6)    ; Restore system copperlist
  76.     Clr    Copjmp1(a6)
  77.     Rts
  78. *****************************************************************************
  79. ;Setup - Setup the menu system
  80. *****************************************************************************
  81. Setup
  82.  
  83. ;-- Remove the sprite data (prevents sprite streaks down the screen)
  84.  
  85.     Lea    Spr0data(a6),a0
  86.     Moveq    #7,d0
  87. Clop
  88.     Clr.l    (a0)
  89.     Addq.l    #8,a0
  90.     Dbf    d0,Clop
  91.  
  92. ;-- Clear the scroll area
  93.  
  94.     Lea    Screen1,a0
  95.     Move    #$bff,d0
  96. Clear_scroll
  97.     Clr.l    (a0)+
  98.     Dbf    d0,Clear_scroll
  99.  
  100. ;-- Initialise some variables
  101.  
  102.     Move.l    #Screen1+80,Current_bank(a5)    ; The two double buffered
  103.     Move.l    #Screen2+80,Other_bank(a5)        ; scroll areas
  104.     Move.l    #Scrolltext,Text_pt(a5)    ; Initialise the scrolltext
  105.     Move    #5,Speed(a5)        ; Set the scroll speed
  106.     Move.l    #Clstart,Cop1lch(a6)    ; Init. our own copperlist
  107.     Clr    Copjmp1(a6)
  108.     Rts
  109.  
  110. *****************************************************************************
  111. ; Main - Central demo calling routine + mouse button check
  112. *****************************************************************************
  113. Main
  114.     Move.l    Vposr(a6),d0
  115.     And.l    #$1ff00,d0
  116.     Cmp.l    #$00100,d0    ; Wait for vertical position 1
  117.     Bne.s    Main
  118.  
  119.     Bsr    Scroller    ; Jump to the scroll routine
  120.  
  121.     Move    #$200,d0    ; Small delay loop, this is needed because
  122. .Loop                 ; in general the scroll routine uses less
  123.     Dbf    d0,.Loop    ; than 1 raster line.As soon as more routines
  124.                 ; are added this is no longer required.
  125.  
  126.     Btst    #6,$bfe001    ; Check the left mouse button
  127.     Bne.s    Main
  128.  
  129.     Rts
  130. *****************************************************************************
  131. ; Scroller -
  132. *****************************************************************************
  133. Scroller
  134.     Move    Scroll_pt(a5),d0
  135.     Add    Speed(a5),d0
  136.     Cmp    #256,d0
  137.     Blt.s    No_bank_change
  138.  
  139.     Move.l    Current_bank(a5),a0
  140.     Move.l    Other_bank(a5),Current_bank(a5)
  141.     Move.l    a0,Other_bank(a5)
  142.     Sub    #256,d0
  143.     Clr    Mode(a5)
  144.  
  145. No_bank_change
  146.     Move    d0,Scroll_pt(a5)
  147.     Move    d0,d1
  148.     Move    d0,d2
  149.     Addq    #1,d2
  150.     Move    d2,d3
  151.  
  152.     Lsr    #4,d0
  153.     Add    d0,d0
  154.     Lsr    #4,d2
  155.     Add    d2,d2
  156.     Add    Current_bank+2(a5),d0
  157.     Add    Current_bank+2(a5),d2
  158.     Sub    #80,d0
  159.     Lea    Scroll_planes+2(pc),a0
  160.     Move    d0,(a0)
  161.     Move    d2,8(a0)
  162.     And    #$0f,d1
  163.     Eor    #$0f,d1
  164.     And    #$0f,d3
  165.     Eor    #$0f,d3
  166.     Lsl    #4,d3
  167.     Or    d3,d1
  168.     Move    d1,Scroll+2
  169.     Cmp    #20,Mode(a5)
  170.     Beq    No_blitting
  171.     Cmp    #12,Mode(a5)
  172.     Blt    Char_scroll
  173. New_chars
  174.     Moveq    #0,d0
  175.     Move    Mode(a5),d2
  176.     Lsl    #2,d2
  177.     Move.l    Other_bank(a5),a2
  178.     Lea    (a2,d2),a2
  179.     Bsr    Read_char
  180.     Addq.l    #2,a2
  181.     Bsr    Read_char
  182.     Bra    Blit_exit
  183.  
  184. Read_char
  185.     Move.l    Text_pt(a5),a0
  186. New_char
  187.     Move.b    (a0)+,d0
  188.     Bne.s    Not_a_null
  189.     Move.l    #Scrolltext,a0
  190.     Bra.s    New_char
  191. Not_a_null
  192.     Cmp    #$20,d0
  193.     Bge.s    Not_control
  194.     Moveq    #$20,d0
  195. Not_control
  196.     Cmp    #$5c,d0
  197.     Beq    Control_char
  198.     Cmp    #$5b,d0
  199.     Blt.s    Not_lower_case
  200.     Sub    #$20,d0
  201. Not_lower_case
  202.     Move.l    a0,Text_pt(a5)
  203.     Sub    #$20,d0
  204.     Add    d0,d0
  205.     Lea    Charpos(pc),a0
  206.     Move    (a0,d0),d1
  207.     Lea    Font(pc),a1
  208.     Lea    (a1,d1),a1
  209.  
  210.     Move.l    #-1,Bltafwm(a6)
  211.     Move.l    a2,Bltdpth(a6)
  212.     Move.l    a1,Bltapth(a6)
  213.     Move.l    #$09f00000,Bltcon0(a6)
  214.     Move.l    #$0026004e,Bltamod(a6)
  215.     Move    #64*16+1,Bltsize(a6)
  216.     Bra    Blit_wait
  217.  
  218.  
  219. Char_scroll
  220.     Move    Mode(a5),d0
  221.     Lsl    #2,d0
  222.     Move.l    Other_bank(a5),a0
  223.     Move.l    Current_bank(a5),a1
  224.     Lea    (a0,d0),a0
  225.     Lea    32(a1,d0),a1
  226.     
  227.     Move.l    #-1,Bltafwm(a6)
  228.     Move.l    a0,Bltdpth(a6)
  229.     Move.l    a1,Bltapth(a6)
  230.     Move.l    #$09f00000,Bltcon0(a6)
  231.     Move.l    #$004c004c,Bltamod(a6)
  232.     Move    #64*16+2,Bltsize(a6)
  233.     Bsr    Blit_wait
  234. Blit_exit
  235.     Addq    #1,Mode(a5)
  236. No_blitting
  237.     Rts
  238.  
  239. Control_char
  240.     Move.b    (a0)+,d0
  241.     Sub    #$40,d0
  242.     Move    d0,Speed(a5)
  243.     Move    #$20,d0
  244.     Bra    Not_lower_case
  245.  
  246.  
  247. Blit_wait
  248.     Btst    #14,Dmaconr(a6)
  249.     Bne.s    Blit_wait
  250.     Rts
  251. *****************************************************************************
  252. ;   Copperlist1 for the menu selector screen
  253. *****************************************************************************
  254. Clstart
  255.     Wait    0,20        ; Give the processor time to update the cl.
  256.     Mov    $9a64,Diwstrt
  257.     Mov    $abd1,Diwstop
  258.     Mov    $0028,Ddfstrt    ; Horizontal scrolling overscan screen
  259.     Mov    $00d8,Ddfstop    ; ie. 368 pixels wide
  260.     
  261.     Mov    0,Color00
  262.     Mov    $666,Color01
  263.     Mov    $fff,Color02
  264.     Mov    $aaa,Color03
  265.     Mov    34,Bpl1mod
  266.     Mov    34,Bpl2mod
  267. Scroll
  268.     Mov    0,Bplcon1
  269.     Mov    0,Bplcon2
  270. Scroll_planes
  271.     Mov    $00,Bpl1ptl
  272.     Mov    7,Bpl1pth
  273.     Mov    $00,Bpl2ptl
  274.     Mov    7,Bpl2pth
  275.     Mov    $2200,Bplcon0
  276.     Wait    $fe,$ff
  277.  
  278. *****************************************************************************
  279. ; Binaries
  280. *****************************************************************************
  281. Font
  282.     Incbin    Binary/Bubble.font
  283.  
  284. Charpos    Dc.w    $0000,$0002,$0004,$0006,$0008,$000a,$000c,$000e ; !"#$%&'
  285.     Dc.w    $0010,$0012,$0014,$0016,$0018,$001a,$001c,$001e ;()*+,-./
  286.     Dc.w    $0020,$0022,$0024,$0026,$0280,$0282,$0284,$0286 ;01234567
  287.     Dc.w    $0288,$028a,$028c,$028e,$0290,$0292,$0294,$0296 ;89:;<=>?
  288.     Dc.w    $0298,$029a,$029c,$029e,$02a0,$02a2,$02a4,$02a6 ;@ADCDEFG
  289.     Dc.w    $0500,$0502,$0504,$0506,$0508,$050a,$050c,$050e ;HIJKLMNO
  290.     Dc.w    $0510,$0512,$0514,$0516,$0518,$051a,$051c,$051e ;PQRSTUVW
  291.     Dc.w    $0520,$0522,$0524,$0526                         ;XYZ[\]^_
  292.  
  293. Scrolltext
  294.     Dc.b    "insert your own scrolltext here !!!"
  295.     Dc.b    "     this scroller was written for "
  296.     Dc.b    "STOLEN DATA, copyright ANARCHY 1990"
  297.     Dc.b    "                                   ",0
  298.     Even
  299.  
  300. *****************************************************************************
  301. ;   Variables
  302. *****************************************************************************
  303.  
  304.     Rsreset
  305. Int_set        Rs.w 1
  306. Dma_set        Rs.w 1
  307. Sys_copl    Rs.l 1
  308. Vbl_vec        Rs.l 1
  309. Scroll_pt    Rs.w 1
  310. Mode        Rs.w 1
  311. Current_bank    Rs.l 1
  312. Other_bank    Rs.l 1
  313. Text_pt        Rs.l 1
  314. Speed        Rs.w 1
  315.  
  316. Varisize    Rs.b 0
  317.  
  318. Variables    Dcb.b Varisize    ; Reserve space for the variables
  319.  
  320.  
  321.  
  322.     Rsset $70000
  323. Screen1        Rs.b 18*80
  324. Screen2        Rs.b 18*80
  325.  
  326.